cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

set(CUR_PROJECT CMakeTutorial)
set(CUR_TARGET CMakeTutorial)

project(${CUR_PROJECT}
    VERSION 0.1.0.0
    DESCRIPTION "CMake Tutotial"
    LANGUAGES CXX
    )

set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")

# set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_CXX_STANDARD_REQUIRED true)
# set(CMAKE_CXX_EXTENSIONS OFF)
add_library(tutorial_compiler_flags INTERFACE)
target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_20)
target_compile_options(tutorial_compiler_flags INTERFACE
  "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>"
  "$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>"
)


configure_file(TutorialConfig.h.in TutorialConfig.h)

add_subdirectory(MathFunctions)

add_executable(${CUR_TARGET}
    tutorial.cxx
)

target_link_libraries(${CUR_TARGET} PRIVATE MathFunctions tutorial_compiler_flags)

# Hint: Be sure to specify the source file as tutorial.cxx

# TODO 9: Use target_include_directories to include ${PROJECT_BINARY_DIR}
target_include_directories(${CUR_TARGET} PRIVATE  
    "${PROJECT_BINARY_DIR}"
    )

message(STATUS  "PROJECT_NAME            ${PROJECT_NAME}")
message(STATUS  "PROJECT_VERSION         ${PROJECT_VERSION}")
message(STATUS  "PROJECT_VERSION_MAJOR   ${PROJECT_VERSION_MAJOR}")
message(STATUS  "PROJECT_VERSION_MINOR   ${PROJECT_VERSION_MINOR}")
message(STATUS  "PROJECT_VERSION_PATCH   ${PROJECT_VERSION_PATCH}")
message(STATUS  "PROJECT_VERSION_TWEAK   ${PROJECT_VERSION_TWEAK}")

message(STATUS  "PROJECT_DESCRIPTION     ${PROJECT_DESCRIPTION}")
message(STATUS  "PROJECT_SOURCE_DIR      ${PROJECT_SOURCE_DIR}")
message(STATUS  "PROJECT_BINARY_DIR      ${PROJECT_BINARY_DIR}")

# 最外层 CMakeLists.txt 所在目录
message(STATUS  "CMAKE_SOURCE_DIR        ${CMAKE_SOURCE_DIR}")